//============================================================================
// Name             : CSE325Project1.cpp
// Author           : Ahbiya Harris ; Alyza Villa
// Effort Division  : 50/50
// Copyright        : CSE325-12456 Embedded Microprocessor Systems
//				      Lab Project 1
//				      Spring 2013
// Description      : Bit manipulations function prototypes.
//============================================================================


#include <iostream>
#include "BitFunctions.h"
using std::cout;
using std::endl;

int main()
{
	CF_LONGWord A;
	CF_Byte B;
	CF_Word C;

	A = ((CF_LONGWord) 0);	// 0000 0000 0000 0000 0000 0000 0000 0000
	B = ((CF_Byte) 14);		// 0000 1010
	C = ((CF_Word) 5777);	// 0000 0011 1100 0000

	cout << A << endl;
	setBit(A, 5);	//test the first setBit function using high number (should wrap to pos 18)
	cout << "Bits: " << getBit(A,5) << endl;
	cout << A << endl;

	A = ((CF_LONGWord) 111); // 0000 0000 0000 0000 0000 1111 1101 1101

	cout << (int)B << endl;
	setByte(A, 3, B);	//test setByte
	cout << "Bytes: " << (int)getByte(A,3) << endl;
	cout << A << endl;

	A = ((CF_LONGWord) 500000); // 0000 0000 0000 0000 0000 0000 0000 0000

	cout << A << endl;
	cout << "Words zero: Before " << getWordLittleEndian(A,0) << endl;
	cout << "Words one: Before " << getWordLittleEndian(A,1) << endl;
	setWord(A, 1, C);	//test setWord
	cout << "Words zero after: " << getWordLittleEndian(A,0) << endl;
	cout << "Words one after: " <<getWordLittleEndian(A,1) << endl;
	cout << A << endl;

	cout << (int)getByte(A, 0) << endl;	//test getByte

	cout << A << endl;
	cout << getWordLittleEndian(C, 0) << endl;	//test getWord

	unsigned int i = 1;
	   char *c = (char*)&i;
	   if (*c)
	       cout << "Little endian\n";
	   else
	       cout << "Big endian\n";
	   //getchar();


	return 0;
}
